<template>
	<!-- 低卡信息加客户 -->
	<view>
		<hx-navbar ref="hxnb" :config="config" @clickBtn="clickBtn"></hx-navbar>
		<!-- list 列表 -->
		<view class="list-view">
			<view class="list-item" @click="toDetail(item,index)" v-for="(item, index) in bottomCardVoList" :key="index">
				<view class="img-box">
					<u--image src="https://cdn.uviewui.com/uview/album/1.jpg" width="80px" height="80px"></u--image>
				</view>
				<view class="con-view p-r-10 p-l-30">
					<view class="name flex">
						<text class="font-bold f-32">{{ item.comegoName || '-' }}</text>
						<u-tag class="m-l-14" :text="item.comegoTypeName ? item.comegoTypeName.slice(0, 1) : '-'" size="mini" plain
							plainFill></u-tag>
					</view>
					<view class="bot-view">
						<text class="f-24">¥</text>
						<text class="f-30 font-bold p-l-4">0</text>
						<text class="f-24">/米</text>
					</view>
				</view>
				<u-icon name="arrow-right" size="10" color="#999"></u-icon>
				<view class="main-icon m-t-10">
					主要
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import clIcon from "@/components/cl-icon/cl-icon.vue";
export default {
	components: {
		clIcon,
	},
	data() {
		return {
			bottomCardVoList: [],
			config: {
				title: "底卡信息",
				color: "#ffffff",
				//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
				backgroundColor: [1, ["#409EFF", "#409EFF", "#60b4f6", "#60b4f6"]],
				rightButton: [
					{
						key: "btn1",
						icon: "&#xe727;",
						position: "left",
					},
				],
			},
		};
	},
	// 页面周期函数--监听页面加载
	onLoad() {
		this.bottomCardVoList = this.$getPageParams('product-information-detail').item || []
		console.log("重新走吗",this.bottomCardVoList);
		uni.$on('on-add-low-calorie', (data,type) => {
			console.log("data,type",data,type);
			if(type.type === "update"){
				this.bottomCardVoList[type.index] = data
			}else{
				this.bottomCardVoList.push(data)
			}
			this.$forceUpdate()
			console.log("this.bottomCardVoList",this.bottomCardVoList);
		})
	},
	methods: {

		clickBtn(item) {
			if (item.key === "btn1") {
				this.$Router.push({
					path: "/pages/application/pages/information/product-information/detail/components/low-calorie/add-low-calorie?type=" + encodeURIComponent(JSON.stringify({type:'add',index:0})),
				});
			}
		},
		scrolltolower(e) {
			// 到底了
		},
		toDetail(item,index) {
			uni.navigateTo({
				url: '/pages/application/pages/information/product-information/detail/components/low-calorie/low-calorie-list-detail?item='+ encodeURIComponent(JSON.stringify(item)) + '&type=' + encodeURIComponent(JSON.stringify({type:'update',index:index}))
			})
		}
	},
	onShow(){
		
	},
	
};
</script>

<style lang="scss" scoped>
.ulist {
	position: absolute;
	top: 5%;
}

.dl-view {
	background-color: #fff;
	padding: 0 20rpx;
	height: 80rpx;
	align-items: center;
	border-bottom: 1rpx solid #eee;

	.dt-view {
		width: 110rpx;
		text-align: right;
	}

	.dd-view {
		flex: 1;
		justify-content: space-between;

		.switch {
			align-items: center;
		}
	}
}

.ul-view {
	overflow: hidden;

	.li-view {
		display: flex;
		align-items: center;
		padding: 14rpx;
		background-color: #fff;
		border-bottom: 1rpx solid #eee;

		.l-text {
			text-align: right;
			width: 120rpx;
		}

		.r-con {
			flex: 1;
			justify-content: space-between;
		}

		.unit {
			justify-content: flex-end;
			color: #666;
			align-items: center;
		}
	}
}

.img-view {
	background-color: #fff;
	padding: 20rpx;

	.img-item {
		position: relative;
	}
}

.table-view {
	background-color: #fff;
	padding: 20rpx;

	.th-view,
	.tr-view {
		display: flex;
	}

	.td-view {
		flex: 1;
		display: flex;
		justify-content: center;

		.inp-box {
			display: flex;
			align-items: center;
		}
	}
}

// list style
.list-view {
	.list-item {
		padding: 20rpx;
		background-color: #fff;
		margin-bottom: 1rpx;
		display: flex;
		justify-content: space-between;

		.con-view {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.bot-view {
				color: #f00;
			}
		}

		.main-icon {
			text-indent: -9999rem;
			width: 10rpx;
			height: 10rpx;
			border-radius: 100%;
			background: #409eff;
		}
	}
}
</style>
